//
//  NSString+composed.h
//  togetherLBS
//
//  Created by Phyllis Hu on 13-4-17.
//  Copyright (c) 2013年 celi. All rights reserved.
//

#import <Foundation/Foundation.h>

typedef enum {
    CLLineBreakByWordWrapping = 0,
    CLLineBreakByCharWrapping,
    CLLineBreakByClipping,
    CLLineBreakByTruncatingHead,
    CLLineBreakByTruncatingTail,
    CLLineBreakByTruncatingMiddle
}CL_LINEBREAK_TYPE;

@interface NSString (composed)
-(BOOL)isComposedOfNumbers;
-(BOOL)isComposedOfNumbersAndLetters;
-(BOOL)isValidEmail;
- (BOOL)isValidPhone;
- (BOOL)isValidPassword;
- (BOOL)isSixNumPassword;

- (NSString *)stringUsedForName;

- (BOOL)containCharacterInString:(NSString *)nStr;
- (NSString *)stringByReplacingAllCharaterInSet:(NSCharacterSet *)sSet byString:(NSString *)nStr;

- (NSString *)URLEncodedString:(NSString *)escaped;
- (NSString *)URLDecodedString;

//在指定了每行显示字符数的情况下，计算字符串需要多少行才能完全显示。
-(NSInteger)lineswithLimit:(NSInteger)num;
-(CGFloat)heightNeededWithFixedWidth:(CGFloat)width andFont:(UIFont *)font;

//计算字符串显示需要的长宽。使用于iOS7 同样可用。
//用于单行显示的
- (CGSize)sizeWithMyFont:(UIFont *)font;
//用于单行显示
- (CGSize)sizeWithMyFont:(UIFont *)font forWidth:(CGFloat)width lineBreakMode:(NSLineBreakMode)lineBreakMode;
//多行显示
- (CGSize)sizeWithMyFont:(UIFont *)font constrainedToSize:(CGSize)size;
//多行显示
- (CGSize)sizeWithMyFont:(UIFont *)font constrainedToSize:(CGSize)size lineBreakMode:(NSLineBreakMode)lineBreakMode;

+ (NSString *)stringWithSchedule:(NSInteger)schedule;
+ (NSString *)stringForTimeFormat:(NSString *)time;
+ (NSString *)stringFromTimeString:(NSString *)timeStr;

/**
 *  根据errorCode生成字符串
 *
 *  @param errorCode 错误码
 *
 *  @return 错误提示字符串
 */
+ (NSString *)stringWithErrorCode:(NSInteger)errorCode;

/**
 *  根据网络连接状态生成字符串
 *
 *  @param status 网络连接状态
 *
 *  @return 网络状态描述字符串
 */
+ (NSString *)stringWithNetworkStatus:(NSInteger)status;

/**
 *  根据情景模式的类型，返回情景模式的名称
 */
+ (NSString *)stringWithModeType:(NSInteger)modeType;

/**
 *  根据@"HH:mm"时间类型的字符串返回半个小时候的字符串
 */
+ (NSString *)stringWithHalfHourAfter:(NSString *)timeStr;

@end
